package tld.test.menu
{
	import flash.display.Sprite;
	import flash.events.Event;
	
	import tld.test.menu.challenges.ChallengeEvent;
	import tld.test.menu.challenges.Quiz;
	
	public class ChallengeTest extends Sprite
	{
		public function ChallengeTest()
		{
			super();
			if (super.stage) this.init();
			else super.addEventListener(
				Event.ADDED_TO_STAGE, this.init);
		}
		
		private function init(event:Event = null):void
		{
			super.removeEventListener(
				Event.ADDED_TO_STAGE, this.init);
			var quiz:Quiz = new Quiz();
			super.addChild(quiz);
			quiz.addEventListener(
				ChallengeEvent.LOOSE, this.looseHandler);
			quiz.addEventListener(ChallengeEvent.WIN, this.winHandler);
			quiz.reset(2, "1 > 2", "3 + 5 = 8", "7 / 3 = 4", "2 * 1/2 < 2");
		}
		
		private function looseHandler(event:ChallengeEvent):void
		{
			trace("Better luck next time.");
		}
		
		private function winHandler(event:ChallengeEvent):void
		{
			trace("The winrar is u.");
		}
	}
}